Option Explicit
Private Sub CommandButton1_Click()
Dim Ans, session, db, View, doc, i, strShtName, Value01, Value02
Ans = MsgBox("Execute?", vbYesNo, "Confirm")
If Ans = vbNo Then Exit Sub
Set session = CreateObject("Notes.NotesSession")
'##### define Notes server and file path
Set db = session.GetDatabase("server", "dir\file.nsf")
'##### get Notes view
Set View = db.getView("view01")
i = 2
Set strShtName = ActiveSheet
Set doc = View.GetFirstDocument
Do Until doc Is Nothing
Value01 = doc.GetItemValue("DB_Value01")
Value02 = doc.GetItemValue("DB_Value02")
strShtName.Cells(i, 2) = Value01(0)
strShtName.Cells(i, 3) = Value02(0)
Set doc = View.GetNextDocument(doc)
i = i + 1
Loop
strShtName.Range(Cells(2, 1), Cells(i, 3)) _
.Sort Key1:=strShtName.Cells(1, 3), order1:=xlAscending, _
Key2:=strShtName.Cells(1, 2), order2:=xlAscending
MsgBox "Finished!"
End Sub
|